#include<bits/stdc++.h>
using namespace std;
long long T;
struct node{
    long long d,v,a;
    bool flag;
}car[100005];
long long monitor[100005],ans,n,m,vmax,l;
long long verbmax(long long x,long long v,long long a){
    return 2*a*x+v*v;
}
bool flag[15];
long long q[2][100005];
bool check(){
    long long ma,mi;
    for(int i=1;i<=n;i++){
        bool flagt=0;
        if(!car[i].flag){
            continue;
        }
        for(int j=1;j<=m;j++){
            if(!flag[j])
            continue;
            if(monitor[j]>=q[0][i]&&monitor[j]<=q[1][i])
            flagt=1;
        }
        if(!flagt)
        return 0;
    }
    return 1;
}
void dfs(long long now,long long num){
    if(now==n+1){
        if(check()){
            if(ans<num){
                ans=num;
            }
        }
        return;
    }
    flag[now]=0;
    dfs(now+1,num+1);
    flag[now]=1;
    dfs(now+1,num);
}
void solve(){
    long long special_t0=0,special_t1=0,special_t2=0;
    bool flag0=1,flag1=1;
    long long maxn=0;
    cin>>n>>m>>l>>vmax;
    for(long long i=1;i<=n;i++){
        cin>>car[i].d>>car[i].v>>car[i].a;
        if(car[i].a!=0)
        flag0=0;
        if(car[i].a<=0)
        flag1=0;
    }
    for(long long i=1;i<=m;i++){
        cin>>monitor[i];
        maxn=max(maxn,monitor[i]);
    }
    if(flag0){
        for(long long i=1;i<=n;i++){
            if(car[i].d<=maxn&&car[i].v>vmax)
            special_t0++;
        }
        if(special_t0==0)
        cout<<0<<" "<<m<<endl;
        else
        cout<<special_t0<<" "<<m-1<<endl;
        return;
    }
    if(flag1){
        for(long long i=1;i<=n;i++){
            if(verbmax(maxn-car[i].d,car[i].v,car[i].a)>vmax*vmax&&car[i].d<=maxn)
            special_t1++;
        }
        if(special_t1==0)
        cout<<0<<" "<<m<<endl;
        else{
            cout<<special_t1<<" "<<m-1<<endl;
        }
        return;
    }
    if(n<=25&&m<=25){
        ans=0;
        int sum=0;
        for(long long i=1;i<=n;i++){
            if(car[i].a==0&&car[i].d<=maxn&&car[i].v>vmax){
                sum++;
                q[0][i]=car[i].d,q[1][i]=maxn;
                car[i].flag=1;
            }
            if(car[i].a>0&&car[i].d<=maxn&&verbmax(maxn-car[i].d,car[i].v,car[i].a)>vmax*vmax){
                car[i].flag=1;
                sum++;
                q[1][i]=maxn;
                float temp;
                temp=(vmax*vmax-car[i].v*car[i].v)/(2*car[i].a);
                long long c;
                c=(long long)temp;
                if(temp!=(float)c)
                q[0][i]=floor(temp)+1+car[i].d;
                else
                q[0][i]=c+car[i].d;
            }
            if(car[i].a<0&&car[i].d<=maxn&&car[i].v>vmax){
                q[0][i]=car[i].d;
                float temp;
                temp=1.00*(vmax*vmax-car[i].v*car[i].v)/(2*car[i].a);
                int c=(int)temp;
                if((float)c==temp)
                q[1][i]=temp+car[i].d-1;
                else
                q[1][i]=temp+car[i].d;
                for(int j=1;j<=m;j++)
                if(monitor[j]>=q[0][i]&&monitor[j]<=q[1][i]){
                    car[i].flag=1;
                    sum++;
                    break;
                }
            }
        }
        memset(flag,true,sizeof(flag));
        dfs(1,0);
        cout<<sum<<" "<<ans<<endl;
        return;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    solve();
    return 0;
}
